﻿Public Class frmMemento
    Public cliente As New Cliente()
    Dim conserje As New ConserjeCliente
    Private Sub frmMemento_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Output.Print("-------------------------")
        Output.Print("--Patrón Memento:")

        Init()
    End Sub

    Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
        conserje.Memento = cliente.ObtenerMemento()
    End Sub

    Private Sub btnRestore_Click(sender As System.Object, e As System.EventArgs) Handles btnRestore.Click
        If Not conserje.Memento Is Nothing Then
            cliente.RestaurarMemento(conserje.Memento)
            Init()
        End If

    End Sub

    Private Sub Init()
        txtNombre.DataBindings.Clear()
        txtTelefono.DataBindings.Clear()
        numVentas.DataBindings.Clear()

        txtNombre.DataBindings.Add("Text", cliente, "Nombre")
        txtTelefono.DataBindings.Add("Text", cliente, "Telefono")
        numVentas.DataBindings.Add("Value", cliente, "ImporteVentas")
    End Sub
End Class